﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZHDJ.PayFactory.AliPayModel;
using ZHDJ.PayFactory.Model;

namespace ZHDJ.PayFactory
{
    /// <summary>
    /// 功能：即时到账交易
    /// </summary>
    public class AliPay : Payment
    {
        public AliPay() { }

        public override string Pay(CommonModel model)
        {
            //把请求参数打包成数组
            SortedDictionary<string, string> sParaTemp = new SortedDictionary<string, string>();
            sParaTemp.Add("service", AlipayConfig.service);
            sParaTemp.Add("partner", AlipayConfig.partner);
            sParaTemp.Add("seller_id", AlipayConfig.seller_id);
            sParaTemp.Add("_input_charset", AlipayConfig.input_charset.ToLower());
            sParaTemp.Add("payment_type", AlipayConfig.payment_type);
            //sParaTemp.Add("notify_url", AlipayConfig.notify_url);
            sParaTemp.Add("return_url", AlipayConfig.return_url);
            sParaTemp.Add("anti_phishing_key", AlipayConfig.anti_phishing_key);
            sParaTemp.Add("exter_invoke_ip", AlipayConfig.exter_invoke_ip);
            sParaTemp.Add("out_trade_no", model.out_trade_no);
            sParaTemp.Add("subject", model.subject);
            sParaTemp.Add("total_fee", model.total_fee);
            sParaTemp.Add("body", model.body);

            //建立请求
            string sHtmlText = AlipaySubmit.BuildRequest(sParaTemp, "get", "确认");
            return sHtmlText;
        }
    }
}
